package {{apiPackage}};

import com.huinong.framework.autoconfigure.feign.HnFeignConfig.FeignExceptionHandler;
import com.huinong.framework.autoconfigure.web.BaseResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Component;
import org.springframework.beans.factory.annotation.Autowired;

{{#importList}}import {{{import}}};
{{/importList}}

@Component
@Slf4j
public class {{feignClientName}}FeignFallbackFactory implements FallbackFactory<{{feignClientName}}Feign> {

  @Autowired
  private FeignExceptionHandler feignExceptionHandler;

  @Override
  public {{feignClientName}}Feign create(Throwable throwable) {
     return new {{feignClientName}}Feign(){

        {{#operations}}
          {{#operation}}
            @Override
            public BaseResult{{#hasBaseResult}}<{{#returnObjectList}}List<{{/returnObjectList}}{{returnObject}}{{#returnObjectList}}>{{/returnObjectList}}>{{/hasBaseResult}} {{functionId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},{{/hasMore}}{{^hasMore}}{{#reactive}}, {{/reactive}}{{/hasMore}}{{/allParams}}) {
              return feignExceptionHandler.handleException(throwable);
            }
          {{/operation}}
        {{/operations}}


      };
    }
}